home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 45
/
Aminet 45 (2001)(GTI - Schatztruhe)[!][Oct 2001].iso
/
Aminet
/
game
/
role
/
ldmud-3.2-bin.lha
/
mud
/
doc
/
LPC
/
types
< prev
next >
Wrap
Text File
|
2001-07-14
|
3KB
|
75 lines
CONCEPT
types
DESCRIPTION
Variables can have the following types:
o int An integer. Normally full 32 bits signed; ranges
are -2,147,483,648 to 2,147,483,648.
Integer values can be specified in decimal, in sedecimal when
preceeded by '0x' (e.g. 0x11), binary when preceeded by
'0b' (e.g. 0b00010001), octal when preceeded by '0o'
(e.g. 0o21) and as character yielding the
charset value for the character as the number to use (e.g. '0'
yields 48 on ASCII machines).
o status OUTDATED - Status was planned to be an optimized
boolean format, but this was never actually
implemented. Statas does work; however, since it
is only an alias for type 'int', just use int.
o string Strings in lpc are true strings, not arrays of characters
as in C (and not pointers to strings). Strings are
mutable -- that is, the contents of a string can be
modified as needed. Strings are automatically concatenated
by the gamedriver at runtime, so the + operator is no
longer strictly necessary to combine two strings.
o object Pointer to an object. Objects are always passed by
reference.
o array Pointer to a vector of values, which could also
be an alist. Arrays take the form ({ n1, n2, n3 })
and may contain any type or a mix of types. Arrays
are always passed by reference. Note that the size
of arrays in LPC, unlike most programming languages,
CAN be changed at run-time.
o mapping An 'associative array' consisting of values indexed by
keys. The indices can be any kind of datatype.
Mappings take the form ([ key1: value1, key2: value2 ]).
By default, mappings are passed by reference.
o closure References to executable code, both to local
functions, efuns and to functions compiled at
run-time ("lambda closures").
o symbol Identifier names, which in essence are quoted strings.
They are used to compute lambda closures, e.g. instead
of ({..., 'ident, ... }) you can write declare a
'symbol' variable foo, compute a value for it, and then
create the closure as ({ ..., foo, ... })
o float A floating point number. The interpreter must have the
floats enabled at compile time.
o mixed A variable allowed to take a value of any type (int,
string, object, array, mapping, float or closure).
All uninitialized variables have the value 0.
The type of a variable is really only for documentation. Unless
you define #pragma strict_types, variables can actually be of
any type and has no effect at all on the program. However, it's
extremely bad style to declare one type but use another, so
please try to avoid this.
A pointer to a destructed object will always have the value 0.
SEE ALSO
alists(LPC), arrays(LPC), mappings(LPC), closures(LPC),
typeof(E), get_type_info(E), inheritance(LPC), pragma(LPC),
modifiers(LPC), escape(LPC)